//
//  WFBaseViewController.m
//  WFTravel
//
//  Created by mc on 2017/11/8.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "LLBaseViewController.h"

@interface LLBaseViewController ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *navTitleLabel;

@end

@implementation LLBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.edgesForExtendedLayout = UIRectEdgeNone;
    
    // UITableview布局 消除顶部空白contentInset, 对iOS10以上的系统可以不加，但是iOS8系统不加的话顶部会有一段空白
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"nav_back"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStyleDone target:self action:@selector(backAction)];
    
    
}

//- (void)setBackArrowImage:(UIImage *)backImage
//{
//    UIButton *backBtn = self.navigationItem.leftBarButtonItem.customView;
//    [backBtn setImage:backImage forState:UIControlStateNormal];
//}


- (void)backAction
{
    if (self.navigationController.viewControllers.count == 1) {
        [self dismissViewControllerAnimated:YES completion:nil];
    } else {
        [self.navigationController popViewControllerAnimated:YES];
    }
}

// 添加轻扫返回手势
- (void)addSwipeGestureRecognizerWithActionBlock:(void (^)(UISwipeGestureRecognizer * _Nonnull))block
{
//    self.fd_interactivePopDisabled = YES;
    // 添加手势，向右滑返回
    UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithActionBlock:^(UISwipeGestureRecognizer *  _Nonnull sender) {
        block(sender);
    }];
    swipe.direction = UISwipeGestureRecognizerDirectionRight;
    [self.view addGestureRecognizer:swipe];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:YES];
}


- (void)dealloc
{
    NSLog(@"[< %@ >] --> 释放了", [self className]);
}

@end
